package io.dy.template.impl;

import io.dy.template.ExcelAndPdfExportTemplate;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author : dmj
 * @date: 2024/7/15 9:53 上午
 * @description:
 */
@Component
public class Demo02ExportImpl extends ExcelAndPdfExportTemplate {
    @Override
    public ExportType exportType() {
        return ExportType.EXCEL;
    }

    @Override
    public String templateUrl() {
        return "/templates/峰谷通周期结算单模版.xlsx";
    }

    @Override
    public <T> ExportData exportData(T req) {
        Map<String, Object> map = new HashMap<>();
        map.put("shipperName", "南京端点科技有限公司");
        map.put("settlementCycle", "2024-07-15 - 2024-09-09");
        map.put("settlementDate", "2024-07-15");
        map.put("settlementCode", "SC9839723912123");

        //超额使用费小计
        map.put("overageGas", "100。00");
        map.put("overageUnit", "/");
        map.put("overageFee", "200。00");
        //逾期使用费小计
        map.put("overdueGas", "100.00");
        map.put("overdueUnit", "/");
        map.put("overdueFee", "281.98");
        //调峰服务费小计行
        map.put("adjustGas", "871.91");
        map.put("adjustUnit", "/");
        map.put("adjustFee", "82.90");
        //峰谷通服务费合计
        map.put("totalFee", "2361.00");
        map.put("remark", "嘻嘻哈哈哈");

        map.put("tabulation", "dy");
        map.put("approval", "sy");
        map.put("finance", "袁童玲");

        ExportData exportData = new ExportData();

        exportData.setObj(map);

        Map<String, Collection<?>> collectionMap = new HashMap<>();

        List<Map<String, Object>> maps = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            Map<String, Object> map1 = new HashMap<>();
            map1.put("serialNo", i + 1);
            map1.put("contractCode", "HT00" + i);
            map1.put("quotaAllocationFormCode", "QAF_" + i);
            map1.put("userName", "dy");
            map1.put("downStationName", "sy");
            map1.put("settlementGas", i * 199);
            map1.put("settlementUnitPrice","1.0");
            map1.put("settlementFee", "10.00");
            maps.add(map1);
        }
        collectionMap.put("overage", maps);



        List<Map<String, Object>> map01 = new ArrayList<>();
        for (int i = 0; i < 8; i++) {
            Map<String, Object> map1 = new HashMap<>();
            map1.put("serialNo", i + 1);
            map1.put("contractCode", "HT00" + i);
            map1.put("quotaAllocationFormCode", "QAF_" + i);
            map1.put("settlementDateStr", "2024年7月8号");
            map1.put("userName", "dy");
            map1.put("downStationName", "sy");
            map1.put("settlementGas", i * 199);
            map1.put("settlementUnitPrice","1.0");
            map1.put("settlementFee", "10.00");
            map01.add(map1);
        }
        collectionMap.put("overdue", map01);


        List<Map<String, Object>> map02 = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            Map<String, Object> map1 = new HashMap<>();
            map1.put("serialNo", i + 1);
            map1.put("contractCode", "HT00" + i);
            map1.put("quotaAllocationFormCode", "QAF_" + i);
            map1.put("userName", "dy");
            map1.put("downStationName", "sy");
            map1.put("settlementGas", i * 199);
            map1.put("settlementUnitPrice","1.0");
            map1.put("settlementFee", "10.00");
            map02.add(map1);
        }
        collectionMap.put("adjust", map02);

        exportData.setCollectionMap(collectionMap);
        exportData.setExportFileName("测试demo.xlsx");
        return exportData;
    }
}
